package com.haizhi.crm.sys.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

@Data
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "t_user")
public class User implements Serializable {
    @Id
    @Column(name = "id")
    private String id;
    @Column(name = "username")
    private String username;
    @Column(name = "email")
    private String email;
    @Column(name = "car")
    private String car;
    @Column(name = "password")
    private String password;

//    @OneToOne(targetEntity = Address.class)
//    @JoinColumn(name = "id", referencedColumnName = "id")
//    private Address address;
//
//    @OneToOne(targetEntity = Identity.class)
//    @JoinColumn(name = "id", referencedColumnName = "id")
//    private Identity identity;

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(
            name = "t_user_role",
            joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")},
            inverseJoinColumns = {@JoinColumn(name = "role_id", referencedColumnName = "id")}
    )
    private List<Role> roles;
}
